<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Hash</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            Hash 
            
                <span class="parent">&lt; 
                    
                    <a href="Object.html">Object</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/array/extract_options_rb.html">activesupport/lib/active_support/core_ext/array/extract_options.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/hash/conversions_rb.html">activesupport/lib/active_support/core_ext/hash/conversions.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/hash/deep_merge_rb.html">activesupport/lib/active_support/core_ext/hash/deep_merge.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/hash/diff_rb.html">activesupport/lib/active_support/core_ext/hash/diff.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/hash/except_rb.html">activesupport/lib/active_support/core_ext/hash/except.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/hash/indifferent_access_rb.html">activesupport/lib/active_support/core_ext/hash/indifferent_access.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/hash/keys_rb.html">activesupport/lib/active_support/core_ext/hash/keys.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/hash/reverse_merge_rb.html">activesupport/lib/active_support/core_ext/hash/reverse_merge.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/hash/slice_rb.html">activesupport/lib/active_support/core_ext/hash/slice.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/object/blank_rb.html">activesupport/lib/active_support/core_ext/object/blank.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/object/deep_dup_rb.html">activesupport/lib/active_support/core_ext/object/deep_dup.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/object/to_param_rb.html">activesupport/lib/active_support/core_ext/object/to_param.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/object/to_query_rb.html">activesupport/lib/active_support/core_ext/object/to_query.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/json/encoding_rb.html">activesupport/lib/active_support/json/encoding.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>A</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-i-assert_valid_keys">assert_valid_keys</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>D</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-i-deep_dup">deep_dup</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-deep_merge">deep_merge</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-deep_merge-21">deep_merge!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-deep_stringify_keys">deep_stringify_keys</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-deep_stringify_keys-21">deep_stringify_keys!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-deep_symbolize_keys">deep_symbolize_keys</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-deep_symbolize_keys-21">deep_symbolize_keys!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-deep_transform_keys">deep_transform_keys</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-deep_transform_keys-21">deep_transform_keys!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-diff">diff</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-i-except">except</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-except-21">except!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-extract-21">extract!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-extractable_options-3F">extractable_options?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-c-from_trusted_xml">from_trusted_xml</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-c-from_xml">from_xml</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-i-nested_under_indifferent_access">nested_under_indifferent_access</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>R</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-i-reverse_merge">reverse_merge</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-reverse_merge-21">reverse_merge!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-reverse_update">reverse_update</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>S</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-i-slice">slice</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-slice-21">slice!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-stringify_keys">stringify_keys</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-stringify_keys-21">stringify_keys!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-symbolize_keys">symbolize_keys</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-symbolize_keys-21">symbolize_keys!</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-i-to_options">to_options</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-to_options-21">to_options!</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-to_param">to_param</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-to_query">to_query</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-to_xml">to_xml</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-transform_keys">transform_keys</a>,
              </li>
            
              
              <li>
                <a href="Hash.html#method-i-transform_keys-21">transform_keys!</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>W</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Hash.html#method-i-with_indifferent_access">with_indifferent_access</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-from_trusted_xml">
            
              <b>from_trusted_xml</b>(xml)
            
            <a href="Hash.html#method-c-from_trusted_xml" name="method-c-from_trusted_xml" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Builds a <a href="Hash.html">Hash</a> from XML just like
<code>Hash.from_xml</code>, but also allows <a
href="Symbol.html">Symbol</a> and YAML.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-from_trusted_xml_source')" id="l_method-c-from_trusted_xml_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/46e0d2397ea10a0bf380926c9fe3cfcf14d5c499/activesupport/lib/active_support/core_ext/hash/conversions.rb#L112" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-from_trusted_xml_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/conversions.rb, line 112</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">from_trusted_xml</span>(<span class="ruby-identifier">xml</span>)
  <span class="ruby-identifier">from_xml</span> <span class="ruby-identifier">xml</span>, []
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-from_xml">
            
              <b>from_xml</b>(xml, disallowed_types = nil)
            
            <a href="Hash.html#method-c-from_xml" name="method-c-from_xml" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a <a href="Hash.html">Hash</a> containing a collection of pairs
when the key is the node name and the value is its content</p>

<pre class="ruby"><span class="ruby-identifier">xml</span> = <span class="ruby-value">&lt;&lt;-XML
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;hash&gt;
      &lt;foo type=&quot;integer&quot;&gt;1&lt;/foo&gt;
      &lt;bar type=&quot;integer&quot;&gt;2&lt;/bar&gt;
    &lt;/hash&gt;
XML</span>

<span class="ruby-identifier">hash</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">xml</span>)
<span class="ruby-comment"># =&gt; {&quot;hash&quot;=&gt;{&quot;foo&quot;=&gt;1, &quot;bar&quot;=&gt;2}}</span>
</pre>

<p>DisallowedType is raise if the XML contains attributes with
<code>type=&quot;yaml&quot;</code> or <code>type=&quot;symbol&quot;</code>.
Use <code>Hash.from_trusted_xml</code> to parse this XML.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-from_xml_source')" id="l_method-c-from_xml_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/46e0d2397ea10a0bf380926c9fe3cfcf14d5c499/activesupport/lib/active_support/core_ext/hash/conversions.rb#L107" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-from_xml_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/conversions.rb, line 107</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">from_xml</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-identifier">disallowed_types</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">XMLConverter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-identifier">disallowed_types</span>).<span class="ruby-identifier">to_h</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-assert_valid_keys">
            
              <b>assert_valid_keys</b>(*valid_keys)
            
            <a href="Hash.html#method-i-assert_valid_keys" name="method-i-assert_valid_keys" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Validate all keys in a hash match <code>*valid_keys</code>, raising
ArgumentError on a mismatch. Note that keys are NOT treated indifferently,
meaning if you use strings for keys but assert symbols as keys, this will
fail.</p>

<pre class="ruby">{ <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-identifier">years</span><span class="ruby-operator">:</span> <span class="ruby-string">'28'</span> }.<span class="ruby-identifier">assert_valid_keys</span>(:<span class="ruby-identifier">name</span>, :<span class="ruby-identifier">age</span>) <span class="ruby-comment"># =&gt; raises &quot;ArgumentError: Unknown key: years&quot;</span>
{ <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-identifier">age</span><span class="ruby-operator">:</span> <span class="ruby-string">'28'</span> }.<span class="ruby-identifier">assert_valid_keys</span>(<span class="ruby-string">'name'</span>, <span class="ruby-string">'age'</span>) <span class="ruby-comment"># =&gt; raises &quot;ArgumentError: Unknown key: name&quot;</span>
{ <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-identifier">age</span><span class="ruby-operator">:</span> <span class="ruby-string">'28'</span> }.<span class="ruby-identifier">assert_valid_keys</span>(:<span class="ruby-identifier">name</span>, :<span class="ruby-identifier">age</span>)   <span class="ruby-comment"># =&gt; passes, raises nothing</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-assert_valid_keys_source')" id="l_method-i-assert_valid_keys_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L67" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-assert_valid_keys_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 67</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">assert_valid_keys</span>(*<span class="ruby-identifier">valid_keys</span>)
  <span class="ruby-identifier">valid_keys</span>.<span class="ruby-identifier">flatten!</span>
  <span class="ruby-identifier">each_key</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Unknown key: #{k}&quot;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">valid_keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_dup">
            
              <b>deep_dup</b>()
            
            <a href="Hash.html#method-i-deep_dup" name="method-i-deep_dup" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a deep copy of hash.</p>

<pre class="ruby"><span class="ruby-identifier">hash</span> = { <span class="ruby-identifier">a</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">b</span><span class="ruby-operator">:</span> <span class="ruby-string">'b'</span> } }
<span class="ruby-identifier">dup</span>  = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">deep_dup</span>
<span class="ruby-identifier">dup</span>[:<span class="ruby-identifier">a</span>][:<span class="ruby-identifier">c</span>] = <span class="ruby-string">'c'</span>

<span class="ruby-identifier">hash</span>[:<span class="ruby-identifier">a</span>][:<span class="ruby-identifier">c</span>] <span class="ruby-comment">#=&gt; nil</span>
<span class="ruby-identifier">dup</span>[:<span class="ruby-identifier">a</span>][:<span class="ruby-identifier">c</span>]  <span class="ruby-comment">#=&gt; &quot;c&quot;</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_dup_source')" id="l_method-i-deep_dup_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/object/deep_dup.rb#L41" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_dup_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/object/deep_dup.rb, line 41</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_dup</span>
  <span class="ruby-identifier">each_with_object</span>(<span class="ruby-identifier">dup</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>), <span class="ruby-identifier">hash</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">deep_dup</span>] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">deep_dup</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_merge">
            
              <b>deep_merge</b>(other_hash, &amp;block)
            
            <a href="Hash.html#method-i-deep_merge" name="method-i-deep_merge" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new hash with <code>self</code> and <code>other_hash</code>
merged recursively.</p>

<pre class="ruby"><span class="ruby-identifier">h1</span> = { <span class="ruby-identifier">x</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">y</span><span class="ruby-operator">:</span> [<span class="ruby-value">4</span>,<span class="ruby-value">5</span>,<span class="ruby-value">6</span>] }, <span class="ruby-identifier">z</span><span class="ruby-operator">:</span> [<span class="ruby-value">7</span>,<span class="ruby-value">8</span>,<span class="ruby-value">9</span>] }
<span class="ruby-identifier">h2</span> = { <span class="ruby-identifier">x</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">y</span><span class="ruby-operator">:</span> [<span class="ruby-value">7</span>,<span class="ruby-value">8</span>,<span class="ruby-value">9</span>] }, <span class="ruby-identifier">z</span><span class="ruby-operator">:</span> <span class="ruby-string">'xyz'</span> }

<span class="ruby-identifier">h1</span>.<span class="ruby-identifier">deep_merge</span>(<span class="ruby-identifier">h2</span>) <span class="ruby-comment">#=&gt; {x: {y: [7, 8, 9]}, z: &quot;xyz&quot;}</span>
<span class="ruby-identifier">h2</span>.<span class="ruby-identifier">deep_merge</span>(<span class="ruby-identifier">h1</span>) <span class="ruby-comment">#=&gt; {x: {y: [4, 5, 6]}, z: [7, 8, 9]}</span>
<span class="ruby-identifier">h1</span>.<span class="ruby-identifier">deep_merge</span>(<span class="ruby-identifier">h2</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">old</span>, <span class="ruby-identifier">new</span><span class="ruby-operator">|</span> <span class="ruby-constant">Array</span>.<span class="ruby-identifier">wrap</span>(<span class="ruby-identifier">old</span>) <span class="ruby-operator">+</span> <span class="ruby-constant">Array</span>.<span class="ruby-identifier">wrap</span>(<span class="ruby-identifier">new</span>) }
<span class="ruby-comment">#=&gt; {:x=&gt;{:y=&gt;[4, 5, 6, 7, 8, 9]}, :z=&gt;[7, 8, 9, &quot;xyz&quot;]}</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_merge_source')" id="l_method-i-deep_merge_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/2ef4d5ed5cbbb2a9266c99535e5f51918ae3e3b6/activesupport/lib/active_support/core_ext/hash/deep_merge.rb#L11" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_merge_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 11</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_merge</span>(<span class="ruby-identifier">other_hash</span>, &amp;<span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">dup</span>.<span class="ruby-identifier">deep_merge!</span>(<span class="ruby-identifier">other_hash</span>, &amp;<span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_merge-21">
            
              <b>deep_merge!</b>(other_hash, &amp;block)
            
            <a href="Hash.html#method-i-deep_merge-21" name="method-i-deep_merge-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Same as <code>deep_merge</code>, but modifies <code>self</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_merge-21_source')" id="l_method-i-deep_merge-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/2ef4d5ed5cbbb2a9266c99535e5f51918ae3e3b6/activesupport/lib/active_support/core_ext/hash/deep_merge.rb#L16" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_merge-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 16</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_merge!</span>(<span class="ruby-identifier">other_hash</span>, &amp;<span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">other_hash</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">tv</span> = <span class="ruby-keyword">self</span>[<span class="ruby-identifier">k</span>]
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">tv</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
      <span class="ruby-keyword">self</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">tv</span>.<span class="ruby-identifier">deep_merge</span>(<span class="ruby-identifier">v</span>, &amp;<span class="ruby-identifier">block</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">self</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">block</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">tv</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">tv</span>, <span class="ruby-identifier">v</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">v</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_stringify_keys">
            
              <b>deep_stringify_keys</b>()
            
            <a href="Hash.html#method-i-deep_stringify_keys" name="method-i-deep_stringify_keys" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Return a new hash with all keys converted to strings. This includes the
keys from the root hash and from all nested hashes.</p>

<pre class="ruby"><span class="ruby-identifier">hash</span> = { <span class="ruby-identifier">person</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-identifier">age</span><span class="ruby-operator">:</span> <span class="ruby-string">'28'</span> } }

<span class="ruby-identifier">hash</span>.<span class="ruby-identifier">deep_stringify_keys</span>
<span class="ruby-comment"># =&gt; { &quot;person&quot; =&gt; { &quot;name&quot; =&gt; &quot;Rob&quot;, &quot;age&quot; =&gt; &quot;28&quot; } }</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_stringify_keys_source')" id="l_method-i-deep_stringify_keys_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L109" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_stringify_keys_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 109</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_stringify_keys</span>
  <span class="ruby-identifier">deep_transform_keys</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_stringify_keys-21">
            
              <b>deep_stringify_keys!</b>()
            
            <a href="Hash.html#method-i-deep_stringify_keys-21" name="method-i-deep_stringify_keys-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Destructively convert all keys to strings. This includes the keys from the
root hash and from all nested hashes.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_stringify_keys-21_source')" id="l_method-i-deep_stringify_keys-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L116" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_stringify_keys-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 116</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_stringify_keys!</span>
  <span class="ruby-identifier">deep_transform_keys!</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_symbolize_keys">
            
              <b>deep_symbolize_keys</b>()
            
            <a href="Hash.html#method-i-deep_symbolize_keys" name="method-i-deep_symbolize_keys" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Return a new hash with all keys converted to symbols, as long as they
respond to <code>to_sym</code>. This includes the keys from the root hash
and from all nested hashes.</p>

<pre class="ruby"><span class="ruby-identifier">hash</span> = { <span class="ruby-string">'person'</span> =<span class="ruby-operator">&gt;</span> { <span class="ruby-string">'name'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-string">'age'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'28'</span> } }

<span class="ruby-identifier">hash</span>.<span class="ruby-identifier">deep_symbolize_keys</span>
<span class="ruby-comment"># =&gt; { person: { name: &quot;Rob&quot;, age: &quot;28&quot; } }</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_symbolize_keys_source')" id="l_method-i-deep_symbolize_keys_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L128" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_symbolize_keys_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 128</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_symbolize_keys</span>
  <span class="ruby-identifier">deep_transform_keys</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">key</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_symbolize_keys-21">
            
              <b>deep_symbolize_keys!</b>()
            
            <a href="Hash.html#method-i-deep_symbolize_keys-21" name="method-i-deep_symbolize_keys-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Destructively convert all keys to symbols, as long as they respond to
<code>to_sym</code>. This includes the keys from the root hash and from all
nested hashes.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_symbolize_keys-21_source')" id="l_method-i-deep_symbolize_keys-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L135" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_symbolize_keys-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 135</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_symbolize_keys!</span>
  <span class="ruby-identifier">deep_transform_keys!</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">key</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_transform_keys">
            
              <b>deep_transform_keys</b>(&amp;block)
            
            <a href="Hash.html#method-i-deep_transform_keys" name="method-i-deep_transform_keys" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Return a new hash with all keys converted by the block operation. This
includes the keys from the root hash and from all nested hashes.</p>

<pre class="ruby"><span class="ruby-identifier">hash</span> = { <span class="ruby-identifier">person</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-identifier">age</span><span class="ruby-operator">:</span> <span class="ruby-string">'28'</span> } }

<span class="ruby-identifier">hash</span>.<span class="ruby-identifier">deep_transform_keys</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span> }
<span class="ruby-comment"># =&gt; { &quot;PERSON&quot; =&gt; { &quot;NAME&quot; =&gt; &quot;Rob&quot;, &quot;AGE&quot; =&gt; &quot;28&quot; } }</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_transform_keys_source')" id="l_method-i-deep_transform_keys_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L82" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_transform_keys_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 82</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_transform_keys</span>(&amp;<span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">result</span> = {}
  <span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">result</span>[<span class="ruby-keyword">yield</span>(<span class="ruby-identifier">key</span>)] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">deep_transform_keys</span>(&amp;<span class="ruby-identifier">block</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-deep_transform_keys-21">
            
              <b>deep_transform_keys!</b>(&amp;block)
            
            <a href="Hash.html#method-i-deep_transform_keys-21" name="method-i-deep_transform_keys-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Destructively convert all keys by using the block operation. This includes
the keys from the root hash and from all nested hashes.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-deep_transform_keys-21_source')" id="l_method-i-deep_transform_keys-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L93" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-deep_transform_keys-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 93</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">deep_transform_keys!</span>(&amp;<span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">value</span> = <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
    <span class="ruby-keyword">self</span>[<span class="ruby-keyword">yield</span>(<span class="ruby-identifier">key</span>)] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">deep_transform_keys!</span>(&amp;<span class="ruby-identifier">block</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-diff">
            
              <b>diff</b>(other)
            
            <a href="Hash.html#method-i-diff" name="method-i-diff" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a hash that represents the difference between two hashes.</p>

<pre class="ruby">{<span class="ruby-value">1</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>}.<span class="ruby-identifier">diff</span>(<span class="ruby-value">1</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>)         <span class="ruby-comment"># =&gt; {}</span>
{<span class="ruby-value">1</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>}.<span class="ruby-identifier">diff</span>(<span class="ruby-value">1</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">3</span>)         <span class="ruby-comment"># =&gt; {1 =&gt; 2}</span>
{}.<span class="ruby-identifier">diff</span>(<span class="ruby-value">1</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>)               <span class="ruby-comment"># =&gt; {1 =&gt; 2}</span>
{<span class="ruby-value">1</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>, <span class="ruby-value">3</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">4</span>}.<span class="ruby-identifier">diff</span>(<span class="ruby-value">1</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>) <span class="ruby-comment"># =&gt; {3 =&gt; 4}</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-diff_source')" id="l_method-i-diff_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/c0c87922baf47eed64a53d3afceba978bb175da9/activesupport/lib/active_support/core_ext/hash/diff.rb#L8" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-diff_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/diff.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">diff</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Deprecation</span>.<span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead.&quot;</span>
  <span class="ruby-identifier">dup</span>.
    <span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">other</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">v</span> }.
    <span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">k</span>) })
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-except">
            
              <b>except</b>(*keys)
            
            <a href="Hash.html#method-i-except" name="method-i-except" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Return a hash that includes everything but the given keys. This is useful
for limiting a set of parameters to everything but a few known toggles:</p>

<pre>@person.update(params[:person].except(:admin))</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-except_source')" id="l_method-i-except_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/1bb020063c1bad6cc6a2ad7a4635bfc31a308f65/activesupport/lib/active_support/core_ext/hash/except.rb#L6" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-except_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/except.rb, line 6</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">except</span>(*<span class="ruby-identifier">keys</span>)
  <span class="ruby-identifier">dup</span>.<span class="ruby-identifier">except!</span>(*<span class="ruby-identifier">keys</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-except-21">
            
              <b>except!</b>(*keys)
            
            <a href="Hash.html#method-i-except-21" name="method-i-except-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Replaces the hash without the given keys.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-except-21_source')" id="l_method-i-except-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/1bb020063c1bad6cc6a2ad7a4635bfc31a308f65/activesupport/lib/active_support/core_ext/hash/except.rb#L11" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-except-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/except.rb, line 11</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">except!</span>(*<span class="ruby-identifier">keys</span>)
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>) }
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-extract-21">
            
              <b>extract!</b>(*keys)
            
            <a href="Hash.html#method-i-extract-21" name="method-i-extract-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Removes and returns the key/value pairs matching the given keys.</p>

<pre class="ruby">{ <span class="ruby-identifier">a</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">:</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">c</span><span class="ruby-operator">:</span> <span class="ruby-value">3</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">:</span> <span class="ruby-value">4</span> }.<span class="ruby-identifier">extract!</span>(:<span class="ruby-identifier">a</span>, :<span class="ruby-identifier">b</span>) <span class="ruby-comment"># =&gt; {:a=&gt;1, :b=&gt;2}</span>
{ <span class="ruby-identifier">a</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">:</span> <span class="ruby-value">2</span> }.<span class="ruby-identifier">extract!</span>(:<span class="ruby-identifier">a</span>, :<span class="ruby-identifier">x</span>)             <span class="ruby-comment"># =&gt; {:a=&gt;1}</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-extract-21_source')" id="l_method-i-extract-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/2ef4d5ed5cbbb2a9266c99535e5f51918ae3e3b6/activesupport/lib/active_support/core_ext/hash/slice.rb#L37" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-extract-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/slice.rb, line 37</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">extract!</span>(*<span class="ruby-identifier">keys</span>)
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each_with_object</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">result</span><span class="ruby-operator">|</span> <span class="ruby-identifier">result</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">key</span>) }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-extractable_options-3F">
            
              <b>extractable_options?</b>()
            
            <a href="Hash.html#method-i-extractable_options-3F" name="method-i-extractable_options-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>By default, only instances of <a href="Hash.html">Hash</a> itself are
extractable. Subclasses of <a href="Hash.html">Hash</a> may implement this
method and return true to declare themselves as extractable. If a <a
href="Hash.html">Hash</a> is extractable, <a
href="Array.html#method-i-extract_options-21">Array#extract_options!</a>
pops it from the <a href="Array.html">Array</a> when it is the last element
of the <a href="Array.html">Array</a>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-extractable_options-3F_source')" id="l_method-i-extractable_options-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/794a70f94485fb64ed1c49ba8532895306e2001c/activesupport/lib/active_support/core_ext/array/extract_options.rb#L7" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-extractable_options-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/array/extract_options.rb, line 7</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">extractable_options?</span>
  <span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">Hash</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-nested_under_indifferent_access">
            
              <b>nested_under_indifferent_access</b>()
            
            <a href="Hash.html#method-i-nested_under_indifferent_access" name="method-i-nested_under_indifferent_access" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Called when object is nested under an object that receives <a
href="Hash.html#method-i-with_indifferent_access">with_indifferent_access</a>.
This method will be called on the current object by the enclosing object
and is aliased to <a
href="Hash.html#method-i-with_indifferent_access">with_indifferent_access</a>
by default. Subclasses of <a href="Hash.html">Hash</a> may overwrite this
method to return <code>self</code> if converting to an
<code>ActiveSupport::HashWithIndifferentAccess</code> would not be
desirable.</p>

<pre>b = { b: 1 }
{ a: b }.with_indifferent_access['a'] # calls b.nested_under_indifferent_access</pre>
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-reverse_merge">
            
              <b>reverse_merge</b>(other_hash)
            
            <a href="Hash.html#method-i-reverse_merge" name="method-i-reverse_merge" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Merges the caller into <code>other_hash</code>. For example,</p>

<pre>options = options.reverse_merge(size: 25, velocity: 10)</pre>

<p>is equivalent to</p>

<pre>options = { size: 25, velocity: 10 }.merge(options)</pre>

<p>This is particularly useful for initializing an options hash with default
values.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-reverse_merge_source')" id="l_method-i-reverse_merge_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/68a8a298d69fdf9cb2a6e3f02568c4d0c02b62ff/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb#L12" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-reverse_merge_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/reverse_merge.rb, line 12</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">reverse_merge</span>(<span class="ruby-identifier">other_hash</span>)
  <span class="ruby-identifier">other_hash</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-reverse_merge-21">
            
              <b>reverse_merge!</b>(other_hash)
            
            <a href="Hash.html#method-i-reverse_merge-21" name="method-i-reverse_merge-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Destructive <code>reverse_merge</code>.</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Hash.html#method-i-reverse_update">reverse_update</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-reverse_merge-21_source')" id="l_method-i-reverse_merge-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/68a8a298d69fdf9cb2a6e3f02568c4d0c02b62ff/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb#L17" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-reverse_merge-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/reverse_merge.rb, line 17</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">reverse_merge!</span>(<span class="ruby-identifier">other_hash</span>)
  <span class="ruby-comment"># right wins if there is no left</span>
  <span class="ruby-identifier">merge!</span>( <span class="ruby-identifier">other_hash</span> ){<span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">left</span>,<span class="ruby-identifier">right</span><span class="ruby-operator">|</span> <span class="ruby-identifier">left</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-reverse_update">
            
              <b>reverse_update</b>(other_hash)
            
            <a href="Hash.html#method-i-reverse_update" name="method-i-reverse_update" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-slice">
            
              <b>slice</b>(*keys)
            
            <a href="Hash.html#method-i-slice" name="method-i-slice" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Slice a hash to include only the given keys. This is useful for limiting an
options hash to valid keys before passing to a method:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier">search</span>(<span class="ruby-identifier">criteria</span> = {})
  <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">assert_valid_keys</span>(:<span class="ruby-identifier">mass</span>, :<span class="ruby-identifier">velocity</span>, :<span class="ruby-identifier">time</span>)
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">search</span>(<span class="ruby-identifier">options</span>.<span class="ruby-identifier">slice</span>(:<span class="ruby-identifier">mass</span>, :<span class="ruby-identifier">velocity</span>, :<span class="ruby-identifier">time</span>))
</pre>

<p>If you have an array of keys you want to limit to, you should splat them:</p>

<pre>valid_keys = [:mass, :velocity, :time]
search(options.slice(*valid_keys))</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-slice_source')" id="l_method-i-slice_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/2ef4d5ed5cbbb2a9266c99535e5f51918ae3e3b6/activesupport/lib/active_support/core_ext/hash/slice.rb#L15" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-slice_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/slice.rb, line 15</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">slice</span>(*<span class="ruby-identifier">keys</span>)
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">map!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">convert_key</span>(<span class="ruby-identifier">key</span>) } <span class="ruby-keyword">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:convert_key</span>, <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each_with_object</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">hash</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-keyword">self</span>[<span class="ruby-identifier">k</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">k</span>) }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-slice-21">
            
              <b>slice!</b>(*keys)
            
            <a href="Hash.html#method-i-slice-21" name="method-i-slice-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Replaces the hash with only the given keys. Returns a hash containing the
removed key/value pairs.</p>

<pre class="ruby">{ <span class="ruby-identifier">a</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">:</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">c</span><span class="ruby-operator">:</span> <span class="ruby-value">3</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">:</span> <span class="ruby-value">4</span> }.<span class="ruby-identifier">slice!</span>(:<span class="ruby-identifier">a</span>, :<span class="ruby-identifier">b</span>)
<span class="ruby-comment"># =&gt; {:c=&gt;3, :d=&gt;4}</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-slice-21_source')" id="l_method-i-slice-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/2ef4d5ed5cbbb2a9266c99535e5f51918ae3e3b6/activesupport/lib/active_support/core_ext/hash/slice.rb#L25" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-slice-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/slice.rb, line 25</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">slice!</span>(*<span class="ruby-identifier">keys</span>)
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">map!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">convert_key</span>(<span class="ruby-identifier">key</span>) } <span class="ruby-keyword">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:convert_key</span>, <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">omit</span> = <span class="ruby-identifier">slice</span>(*<span class="ruby-keyword">self</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">keys</span>)
  <span class="ruby-identifier">hash</span> = <span class="ruby-identifier">slice</span>(*<span class="ruby-identifier">keys</span>)
  <span class="ruby-identifier">replace</span>(<span class="ruby-identifier">hash</span>)
  <span class="ruby-identifier">omit</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-stringify_keys">
            
              <b>stringify_keys</b>()
            
            <a href="Hash.html#method-i-stringify_keys" name="method-i-stringify_keys" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Return a new hash with all keys converted to strings.</p>

<pre class="ruby"><span class="ruby-identifier">hash</span> = { <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-identifier">age</span><span class="ruby-operator">:</span> <span class="ruby-string">'28'</span> }

<span class="ruby-identifier">hash</span>.<span class="ruby-identifier">stringify_keys</span>
<span class="ruby-comment">#=&gt; { &quot;name&quot; =&gt; &quot;Rob&quot;, &quot;age&quot; =&gt; &quot;28&quot; }</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-stringify_keys_source')" id="l_method-i-stringify_keys_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L31" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-stringify_keys_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 31</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">stringify_keys</span>
  <span class="ruby-identifier">transform_keys</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-stringify_keys-21">
            
              <b>stringify_keys!</b>()
            
            <a href="Hash.html#method-i-stringify_keys-21" name="method-i-stringify_keys-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Destructively convert all keys to strings. Same as
<code>stringify_keys</code>, but modifies <code>self</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-stringify_keys-21_source')" id="l_method-i-stringify_keys-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L37" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-stringify_keys-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 37</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">stringify_keys!</span>
  <span class="ruby-identifier">transform_keys!</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-symbolize_keys">
            
              <b>symbolize_keys</b>()
            
            <a href="Hash.html#method-i-symbolize_keys" name="method-i-symbolize_keys" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Return a new hash with all keys converted to symbols, as long as they
respond to <code>to_sym</code>.</p>

<pre class="ruby"><span class="ruby-identifier">hash</span> = { <span class="ruby-string">'name'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-string">'age'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'28'</span> }

<span class="ruby-identifier">hash</span>.<span class="ruby-identifier">symbolize_keys</span>
<span class="ruby-comment">#=&gt; { name: &quot;Rob&quot;, age: &quot;28&quot; }</span>
</pre>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Hash.html#method-i-to_options">to_options</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-symbolize_keys_source')" id="l_method-i-symbolize_keys_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L48" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-symbolize_keys_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 48</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">symbolize_keys</span>
  <span class="ruby-identifier">transform_keys</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">key</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-symbolize_keys-21">
            
              <b>symbolize_keys!</b>()
            
            <a href="Hash.html#method-i-symbolize_keys-21" name="method-i-symbolize_keys-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Destructively convert all keys to symbols, as long as they respond to
<code>to_sym</code>. Same as <code>symbolize_keys</code>, but modifies
<code>self</code>.</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Hash.html#method-i-to_options-21">to_options!</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-symbolize_keys-21_source')" id="l_method-i-symbolize_keys-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L55" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-symbolize_keys-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 55</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">symbolize_keys!</span>
  <span class="ruby-identifier">transform_keys!</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">key</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_options">
            
              <b>to_options</b>()
            
            <a href="Hash.html#method-i-to_options" name="method-i-to_options" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_options-21">
            
              <b>to_options!</b>()
            
            <a href="Hash.html#method-i-to_options-21" name="method-i-to_options-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_param">
            
              <b>to_param</b>(namespace = nil)
            
            <a href="Hash.html#method-i-to_param" name="method-i-to_param" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a string representation of the receiver suitable for use as a URL
query string:</p>

<pre class="ruby">{<span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'David'</span>, <span class="ruby-identifier">nationality</span><span class="ruby-operator">:</span> <span class="ruby-string">'Danish'</span>}.<span class="ruby-identifier">to_param</span>
<span class="ruby-comment"># =&gt; &quot;name=David&amp;nationality=Danish&quot;</span>
</pre>

<p>An optional namespace can be passed to enclose the param names:</p>

<pre class="ruby">{<span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'David'</span>, <span class="ruby-identifier">nationality</span><span class="ruby-operator">:</span> <span class="ruby-string">'Danish'</span>}.<span class="ruby-identifier">to_param</span>(<span class="ruby-string">'user'</span>)
<span class="ruby-comment"># =&gt; &quot;user[name]=David&amp;user[nationality]=Danish&quot;</span>
</pre>

<p>The string pairs “key=value” that conform the query string are sorted
lexicographically in ascending order.</p>

<p>This method is also aliased as <code>to_query</code>.</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Hash.html#method-i-to_query">to_query</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-to_param_source')" id="l_method-i-to_param_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/03404936945b452b8e66e53e183973176dae8301/activesupport/lib/active_support/core_ext/object/to_param.rb#L53" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-to_param_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/object/to_param.rb, line 53</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_param</span>(<span class="ruby-identifier">namespace</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">collect</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_query</span>(<span class="ruby-identifier">namespace</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{namespace}[#{key}]&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">key</span>)
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">sort</span> * <span class="ruby-string">'&amp;'</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_query">
            
              <b>to_query</b>(namespace = nil)
            
            <a href="Hash.html#method-i-to_query" name="method-i-to_query" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_xml">
            
              <b>to_xml</b>(options = {})
            
            <a href="Hash.html#method-i-to_xml" name="method-i-to_xml" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a string containing an XML representation of its receiver:</p>

<pre class="ruby">{<span class="ruby-string">'foo'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>, <span class="ruby-string">'bar'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>}.<span class="ruby-identifier">to_xml</span>
<span class="ruby-comment"># =&gt;</span>
<span class="ruby-comment"># &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="ruby-comment"># &lt;hash&gt;</span>
<span class="ruby-comment">#   &lt;foo type=&quot;integer&quot;&gt;1&lt;/foo&gt;</span>
<span class="ruby-comment">#   &lt;bar type=&quot;integer&quot;&gt;2&lt;/bar&gt;</span>
<span class="ruby-comment"># &lt;/hash&gt;</span>
</pre>

<p>To do so, the method loops over the pairs and builds nodes that depend on
the <em>values</em>. Given a pair <code>key</code>, <code>value</code>:</p>
<ul><li>
<p>If <code>value</code> is a hash there’s a recursive call with
<code>key</code> as <code>:root</code>.</p>
</li><li>
<p>If <code>value</code> is an array there’s a recursive call with
<code>key</code> as <code>:root</code>, and <code>key</code> singularized
as <code>:children</code>.</p>
</li><li>
<p>If <code>value</code> is a callable object it must expect one or two
arguments. Depending on the arity, the callable is invoked with the
<code>options</code> hash as first argument with <code>key</code> as
<code>:root</code>, and <code>key</code> singularized as second argument.
The callable can add nodes by using <code>options[:builder]</code>.</p>

<pre class="ruby"><span class="ruby-string">'foo'</span>.<span class="ruby-identifier">to_xml</span>(<span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">options</span>, <span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[:<span class="ruby-identifier">builder</span>].<span class="ruby-identifier">b</span>(<span class="ruby-identifier">key</span>) })
<span class="ruby-comment"># =&gt; &quot;&lt;b&gt;foo&lt;/b&gt;&quot;</span>
</pre>
</li><li>
<p>If <code>value</code> responds to <code>to_xml</code> the method is invoked
with <code>key</code> as <code>:root</code>.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Foo</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">to_xml</span>(<span class="ruby-identifier">options</span>)
    <span class="ruby-identifier">options</span>[:<span class="ruby-identifier">builder</span>].<span class="ruby-identifier">bar</span> <span class="ruby-string">'fooing!'</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

{ <span class="ruby-identifier">foo</span><span class="ruby-operator">:</span> <span class="ruby-constant">Foo</span>.<span class="ruby-identifier">new</span> }.<span class="ruby-identifier">to_xml</span>(<span class="ruby-identifier">skip_instruct</span><span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-comment"># =&gt; &quot;&lt;hash&gt;&lt;bar&gt;fooing!&lt;/bar&gt;&lt;/hash&gt;&quot;</span>
</pre>
</li><li>
<p>Otherwise, a node with <code>key</code> as tag is created with a string
representation of <code>value</code> as text node. If <code>value</code> is
<code>nil</code> an attribute “nil” set to “true” is added. Unless the
option <code>:skip_types</code> exists and is true, an attribute “type” is
added as well according to the following mapping:</p>

<pre class="ruby"><span class="ruby-constant">XML_TYPE_NAMES</span> = {
  <span class="ruby-string">&quot;Symbol&quot;</span>     =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;symbol&quot;</span>,
  <span class="ruby-string">&quot;Fixnum&quot;</span>     =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;integer&quot;</span>,
  <span class="ruby-string">&quot;Bignum&quot;</span>     =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;integer&quot;</span>,
  <span class="ruby-string">&quot;BigDecimal&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;decimal&quot;</span>,
  <span class="ruby-string">&quot;Float&quot;</span>      =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;float&quot;</span>,
  <span class="ruby-string">&quot;TrueClass&quot;</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;boolean&quot;</span>,
  <span class="ruby-string">&quot;FalseClass&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;boolean&quot;</span>,
  <span class="ruby-string">&quot;Date&quot;</span>       =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;date&quot;</span>,
  <span class="ruby-string">&quot;DateTime&quot;</span>   =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;dateTime&quot;</span>,
  <span class="ruby-string">&quot;Time&quot;</span>       =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;dateTime&quot;</span>
}
</pre>
</li></ul>

<p>By default the root node is “hash”, but that’s configurable via the
<code>:root</code> option.</p>

<p>The default XML builder is a fresh instance of
<code>Builder::XmlMarkup</code>. You can configure your own builder with
the <code>:builder</code> option. The method also accepts options like
<code>:dasherize</code> and friends, they are forwarded to the builder.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-to_xml_source')" id="l_method-i-to_xml_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/46e0d2397ea10a0bf380926c9fe3cfcf14d5c499/activesupport/lib/active_support/core_ext/hash/conversions.rb#L71" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-to_xml_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/conversions.rb, line 71</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_xml</span>(<span class="ruby-identifier">options</span> = {})
  <span class="ruby-identifier">require</span> <span class="ruby-string">'active_support/builder'</span> <span class="ruby-keyword">unless</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">Builder</span>)

  <span class="ruby-identifier">options</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">options</span>[<span class="ruby-value">:indent</span>]  <span class="ruby-operator">||=</span> <span class="ruby-number">2</span>
  <span class="ruby-identifier">options</span>[<span class="ruby-value">:root</span>]    <span class="ruby-operator">||=</span> <span class="ruby-string">'hash'</span>
  <span class="ruby-identifier">options</span>[<span class="ruby-value">:builder</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Builder</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMarkup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">indent</span><span class="ruby-operator">:</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:indent</span>])

  <span class="ruby-identifier">builder</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:builder</span>]
  <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">instruct!</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:skip_instruct</span>)

  <span class="ruby-identifier">root</span> = <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMini</span>.<span class="ruby-identifier">rename_key</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:root</span>].<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">options</span>)

  <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">tag!</span>(<span class="ruby-identifier">root</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMini</span>.<span class="ruby-identifier">to_tag</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span>) }
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">builder</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-transform_keys">
            
              <b>transform_keys</b>()
            
            <a href="Hash.html#method-i-transform_keys" name="method-i-transform_keys" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Return a new hash with all keys converted using the block operation.</p>

<pre class="ruby"><span class="ruby-identifier">hash</span> = { <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-string">'Rob'</span>, <span class="ruby-identifier">age</span><span class="ruby-operator">:</span> <span class="ruby-string">'28'</span> }

<span class="ruby-identifier">hash</span>.<span class="ruby-identifier">transform_keys</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span> }
<span class="ruby-comment"># =&gt; { &quot;NAME&quot; =&gt; &quot;Rob&quot;, &quot;AGE&quot; =&gt; &quot;28&quot; }</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-transform_keys_source')" id="l_method-i-transform_keys_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L8" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-transform_keys_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">transform_keys</span>
  <span class="ruby-identifier">result</span> = {}
  <span class="ruby-identifier">each_key</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">result</span>[<span class="ruby-keyword">yield</span>(<span class="ruby-identifier">key</span>)] = <span class="ruby-keyword">self</span>[<span class="ruby-identifier">key</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-transform_keys-21">
            
              <b>transform_keys!</b>()
            
            <a href="Hash.html#method-i-transform_keys-21" name="method-i-transform_keys-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Destructively convert all keys using the block operations. Same as <a
href="Hash.html#method-i-transform_keys">#transform_keys</a> but modifies
<code>self</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-transform_keys-21_source')" id="l_method-i-transform_keys-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/keys.rb#L18" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-transform_keys-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/keys.rb, line 18</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">transform_keys!</span>
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">self</span>[<span class="ruby-keyword">yield</span>(<span class="ruby-identifier">key</span>)] = <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-with_indifferent_access">
            
              <b>with_indifferent_access</b>()
            
            <a href="Hash.html#method-i-with_indifferent_access" name="method-i-with_indifferent_access" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns an <code>ActiveSupport::HashWithIndifferentAccess</code> out of its
receiver:</p>

<pre class="ruby">{ <span class="ruby-identifier">a</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span> }.<span class="ruby-identifier">with_indifferent_access</span>[<span class="ruby-string">'a'</span>] <span class="ruby-comment"># =&gt; 1</span>
</pre>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Hash.html#method-i-nested_under_indifferent_access">nested_under_indifferent_access</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-with_indifferent_access_source')" id="l_method-i-with_indifferent_access_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb#L8" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-with_indifferent_access_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">with_indifferent_access</span>
  <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">HashWithIndifferentAccess</span>.<span class="ruby-identifier">new_from_hash_copying_default</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    